package a9;

public abstract class GeoAngle {
	
	double ANGLE;  //in degrees
	/**
	 * @return max range in degrees
	 */
	
	public abstract double getMaxRange();

	public GeoAngle (double rad) {
		if(Math.abs(rad) > getMaxRange())
			throw new IllegalArgumentException("Angle out of range");
	}

		public double toDMS (int deg, int min, double sec) {
			return(deg + min / 60. + sec / 3600.);
		}
		
	private static double toRadians(double degLongitude) {
		return degLongitude * Math.PI / 180.;
	}

	public double getDegAngle() {
		return this.ANGLE * 180. / Math.PI;
	}

	public String getDMSLat() {
		int deg = 0;
		int min = 0;
		double sec = 0;

		deg = (int) ANGLE;
		min = (int) ((ANGLE - deg) * 60);
		sec = ((ANGLE - deg) * 60 - min) * 60;

		String time = String.format("%d\u00b0%d\'%.1f\"", deg, min, sec);
		return time;
	}

	public double getLon() {
		return ANGLE;
	}
}
